home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 12 / 012.d81 / dos #30 < prev    next >
Text File  |  2022-08-26  |  4KB  |  225 lines

  1.  
  2.      DOS & Don'ts -- Part 30
  3.           by Jimmy Weiler
  4.  
  5.  
  6.  
  7. 1110 FOR C1=164 TO 255: GET#8,K$: NEXT
  8.  
  9.   We are not interested in the next
  10.  
  11. 91 characters, so we throw them away.
  12.  
  13.  
  14. 1120 FOR FILE=1 TO 144
  15.  
  16.   Here we start reading the file
  17.  
  18. names out of the directory.  There
  19.  
  20. is room for 144 files in a normal
  21.  
  22. 1541 directory.
  23.  
  24.  
  25. 1130 FOR BYTE=0 TO 29: GET#8,F$(BYTE):
  26.      NEXT: IF ST=66 THEN FILE=150:
  27.      GOTO 1240
  28.  
  29.   Each file name in a directory
  30.  
  31. is 29 characters long.  We read those
  32.  
  33. characters into our file name array,
  34.  
  35. F$.  If we reach the end of the
  36.  
  37. directory while we read the file name,
  38.  
  39. STATUS will equal 66.  In that case,
  40.  
  41. we set our file counter to 150 and
  42.  
  43. exit the for-next loop we are using
  44.  
  45. to read the file names.
  46.  
  47.  
  48. 1140 F$(0)=F$(0)+Z$
  49. 1150 IF F$(0)<IL$ THEN 1220
  50.  
  51.   The first character of any directory
  52.  
  53. file entry describes the file type.
  54.  
  55. These are:
  56.  
  57.   DELeted:    0 or 128
  58.   SEQuential: 129
  59.   PRoGram:    130
  60.   USeR:       131
  61.   RELative:   132
  62.  
  63. If the file name we are processing
  64.  
  65. was scratched from the directory or
  66.  
  67. improperly closed this code will let
  68.  
  69. us proceed to the next file.
  70.  
  71.  
  72. 1160 PRINT TY$(ASC(F$(0))-128);": ";
  73.  
  74.   We subtract 128 from the file type
  75.  
  76. character, use the resulting value to
  77.  
  78. index into TY$, and print the
  79.  
  80. appropriate type.
  81.  
  82.  
  83. 1170 PRINT Q$;:FOR LTTR=3 TO 18:
  84.      IF F$(LTTR)<>SP$ THEN PRINT
  85.      F$(LTTR);
  86. 1180 NEXT: PRINT Q$;
  87.  
  88.   We print the file name in quotes.
  89.  
  90. If we encounter a shifted space (SP$)
  91.  
  92. before the sixteenth character, it
  93.  
  94. means we have reached the end of the
  95.  
  96. file name.
  97.  
  98.  
  99. 1190 SZ=256*ASC(F$(29)+Z$)+ASC(F$(28))
  100.  
  101.   The 28th and 29th characters of each
  102.  
  103. file name entry contain the size in
  104.  
  105. blocks of that particular file.  This
  106.  
  107. code calculates that size.
  108.  
  109.  
  110. 1200 PRINT TAB(23-(SZ<100)-(SZ<10))SZ
  111.      "BLOCK";:IF SZ<>1 THEN PRINT "S";
  112.  
  113.   To make the file size column of our
  114.  
  115. printout line up nicely, we use some
  116.  
  117. BOOLEAN magic.  Any expression that
  118.  
  119. evaluates as either true or false is
  120.  
  121. said to be a Boolean expression.
  122.  
  123. "E = F" is an example.  If the value
  124.  
  125. of E equals the value of F then the
  126.  
  127. expression is true.  Otherwise it is
  128.  
  129. false.
  130.  
  131.   When your Commodore evaluates
  132.  
  133. a Boolean expression as "true" it
  134.  
  135. assigns a value of -1 to the result.
  136.  
  137. "False" evaluates as 0.
  138.  
  139.   10 LET E=1: LET F=1
  140.   20 LET B = E = F
  141.   30 PRINT B
  142.  
  143. Line 30 of this example will print -1.
  144.  
  145.   The Boolean calculations in line
  146.  
  147. 1200 will add 1 to the TAB position if
  148.  
  149. the size of the file is less than 100
  150.  
  151. and will add one more if the size is
  152.  
  153. also less than 10.
  154.  
  155.  
  156. 1210 PRINT
  157.  
  158.   We print a carriage return because
  159.  
  160. we have finished with the file name
  161.  
  162. we were working on.
  163.  
  164.  
  165. 1220 IF FILE/8<>INT(FILE/8) THEN
  166.      GET#8,L$,M$
  167.  
  168.   Every directory block on the disk
  169.  
  170. can hold eight file names.  There
  171.  
  172. are two unused characters between each
  173.  
  174. of the names.  We GET# those
  175.  
  176. characters and throw them away.
  177.  
  178. However, between the last file entry
  179.  
  180. in one block and the first entry in
  181.  
  182. the next there are NO unused
  183.  
  184. characters.  So, every eight file
  185.  
  186. names, we DON'T GET# those extra
  187.  
  188. characters.
  189.  
  190.  
  191. 1230 BU=BU+SZ: SZ=0
  192.  
  193.   We add the size of the last file
  194.  
  195. to the number of blocks used on the
  196.  
  197. disk.
  198.  
  199.  
  200. 1240 NEXT FILE:
  201.      PRINT BU"OF 664 BLOCKS USED."
  202.  
  203.   This is the end of the for-next
  204.  
  205. loop that counts through the
  206.  
  207. files in the directory.  When we have
  208.  
  209. printed the last file, we then
  210.  
  211. print the number of blocks they have
  212.  
  213. used.
  214.  
  215.  
  216. 1250 CLOSE 8: CLOSE 15
  217.  
  218.   When we're done, we close all the
  219.  
  220. disk I/O channels we used to read the
  221.  
  222. directory.
  223.  
  224. -------< continued in Part 31 >-------
  225.